//
//  SAShopListCollectionView.m
//  YunFu
//
//  Created by Bager on 2018/9/11.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "SAShopListCollectionView.h"

#import "SAShopListGoodsCell.h"

@implementation SAShopListCollectionView

- (instancetype)init
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    // 设置每个item的大小，
    flowLayout.itemSize = CGSizeMake((kScreenWidth - kPublicMargin * 2 - 20) / 3.0, 150);
    // 设置列的最小间距
    flowLayout.minimumInteritemSpacing = 10;
    // 设置最小行间距
    flowLayout.minimumLineSpacing = 10;
    // 设置布局的内边距
    flowLayout.sectionInset = UIEdgeInsetsMake(0, kPublicMargin, 0, kPublicMargin);
    // 滚动方向
//    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self = [super initWithFrame:CGRectMake(0, 40, kScreenWidth, 160)  collectionViewLayout:flowLayout];
    
    self.backgroundColor = [UIColor whiteColor];
    
    if (self)
    {
        self.dataSource = self;
        
        self.delegate = self;
        
        [self registerClass:[SAShopListGoodsCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
    }
    
    return self;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 3;
}

- (UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SAShopListGoodsCell *cell =  [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
    
//    [cell.img setImage:[UIImage imageNamed:imgArray[indexPath.item]]];
//    cell.name.text = titleArray[indexPath.item];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    UINavigationController *nav = (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    
}

@end
